package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-04-14 01:42
 */
public class MergeInBetween {
    public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {

        ListNode nodeA = list1, nodeB = list1, node2 = list2;
        while (b > -2) {
            if (a > 0) nodeA = nodeA.next;
            nodeB = nodeB.next;
            b--;
            a--;
        }
        nodeA.next = list2;
        while (node2.next != null) {
            node2 = node2.next;
        }
        node2.next = nodeB;
        return list1;

    }
}
